package com.ruoyi.partscore.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.partscore.domain.PartScore;
import com.ruoyi.partscore.service.IPartScoreService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 支部积分Controller
 * 
 * @author ruoyi
 * @date 2023-09-26
 */
@RestController
@RequestMapping("/partscore/partscore")
public class PartScoreController extends BaseController
{
    @Autowired
    private IPartScoreService partScoreService;

    /**
     * 查询支部积分列表
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:list')")
    @GetMapping("/list")
    public TableDataInfo list(PartScore partScore)
    {
        startPage();
        List<PartScore> list = partScoreService.selectPartScoreList(partScore);
        return getDataTable(list);
    }

    /**
     * 导出支部积分列表
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:export')")
    @Log(title = "支部积分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PartScore partScore)
    {
        List<PartScore> list = partScoreService.selectPartScoreList(partScore);
        ExcelUtil<PartScore> util = new ExcelUtil<PartScore>(PartScore.class);
        util.exportExcel(response, list, "支部积分数据");
    }

    /**
     * 获取支部积分详细信息
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(partScoreService.selectPartScoreById(id));
    }

    /**
     * 新增支部积分
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:add')")
    @Log(title = "支部积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PartScore partScore)
    {
        return toAjax(partScoreService.insertPartScore(partScore));
    }

    /**
     * 修改支部积分
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:edit')")
    @Log(title = "支部积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PartScore partScore)
    {
        return toAjax(partScoreService.updatePartScore(partScore));
    }

    /**
     * 删除支部积分
     */
    @PreAuthorize("@ss.hasPermi('partscore:partscore:remove')")
    @Log(title = "支部积分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(partScoreService.deletePartScoreByIds(ids));
    }
}
